package com.itcoon.transform.starter.config;

import com.itcoon.common.utils.SpringUtils;
import com.itcoon.transform.assemble.handler.AssembleHandlerComposite;
import com.itcoon.transform.assemble.validator.*;
import com.itcoon.transform.base.TransformHandlerComposite;
import com.itcoon.transform.base.register.annotated.AnnotatedAssembleModelRegister;
import com.itcoon.transform.base.register.annotated.AnnotatedAssembleModelRegisterComposite;
import com.itcoon.transform.base.register.annotated.AnnotatedClazzAssembleModelRegister;
import com.itcoon.transform.base.register.annotated.AnnotatedInterAssembleModelRegister;
import com.itcoon.transform.base.register.unannotated.UnAnnotatedAssembleModelRegisterComposite;
import com.itcoon.transform.base.register.unannotated.UnAnnotatedClazzAssembleModelRegister;
import com.itcoon.transform.base.register.unannotated.UnAnnotatedIInterAssembleModelRegister;
import com.itcoon.transform.base.register.unannotated.UnAnnotedAssembleModelRegister;
import com.itcoon.transform.starter.handler.ClazzTransformHandler;
import com.itcoon.transform.starter.handler.InterTransformHandler;
import com.itcoon.transform.starter.handler.TransformHandler;
import com.itcoon.transform.starter.handler.TransformHandlerCompositeImpl;
import com.itcoon.transform.assemble.converter.AssembleConverterComposite;
import com.itcoon.transform.assemble.converter.IntegerToCodeEnumConverter;
import com.itcoon.transform.assemble.handler.clazz.AssembleForTargetClassHandler;
import com.itcoon.transform.assemble.handler.clazz.StandardTargetClassHandler;
import com.itcoon.transform.assemble.handler.clazz.TargetArrayHandler;
import com.itcoon.transform.assemble.handler.clazz.TargetReferenceHandler;
import com.itcoon.transform.assemble.handler.parameterized.AssembleForTargetParameterizedTypeHandler;
import com.itcoon.transform.assemble.handler.parameterized.StandardTargetParameterizedTypeHandler;
import com.itcoon.transform.assemble.handler.parameterized.TargetCollectionHandler;
import com.itcoon.transform.assemble.handler.parameterized.TargetMapHandler;
import com.itcoon.transform.base.init.AnnotatedModelDefinitionInitializer;
import com.itcoon.transform.assemble.assembler.inter.ModelPropertyAssembler;
import com.itcoon.transform.assemble.assembler.inter.InterDefaultMethodAssembler;
import com.itcoon.transform.assemble.assembler.inter.MethodAssembler;
import com.itcoon.transform.assemble.assembler.inter.MethodAssemblerComposite;
import com.itcoon.transform.inject.InjectHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

public class TransformBeanConfig {

    @Bean
    public AnnotatedModelDefinitionInitializer annotatedModelDefinitionInitializer() {
        return new AnnotatedModelDefinitionInitializer();
    }

    @Bean
    public AnnotatedAssembleModelRegisterComposite assembleModelRegisterComposite() {
        return new AnnotatedAssembleModelRegisterComposite();
    }

    @Bean
    public UnAnnotatedAssembleModelRegisterComposite unAssembleModelRegisterComposite() {
        return new UnAnnotatedAssembleModelRegisterComposite();
    }

    @Bean
    public AnnotatedAssembleModelRegister annotatedClazzAssembleModelRegister() {
        return new AnnotatedClazzAssembleModelRegister();
    }

    @Bean
    public AnnotatedAssembleModelRegister annotatedInterAssembleModelRegister() {
        return new AnnotatedInterAssembleModelRegister();
    }

    @Bean
    public UnAnnotedAssembleModelRegister unAnnotedClazzAssembleModelRegister(){
        return new UnAnnotatedClazzAssembleModelRegister();
    }

    @Bean
    public UnAnnotedAssembleModelRegister unAnnotedInterAssembleModelRegister(){
        return new UnAnnotatedIInterAssembleModelRegister();
    }

    @Bean
    public TransformHandlerComposite transformHandlerComposite() {
        return new TransformHandlerCompositeImpl();
    }

    @Bean
    public TransformHandler interTransformHandler() {
        return new InterTransformHandler();
    }

    @Bean
    public TransformHandler clazzTransformHandler() {
        return new ClazzTransformHandler();
    }

    @Bean
    public SourceValidatorComposite sourceValidatorComposite(){
        return new SourceValidatorComposite();
    }

    @Bean
    public SourceValidator transform4jProxyValidator(){
        return new Transform4jProxyValidator();
    }

    @Bean
    public SourceValidator anonymousValidator(){
        return new AnonymousValidator();
    }

    @Bean
    public SourceValidator standardValidator(){
        return new StandardSourceValidator();
    }

    @Bean
    public MethodAssemblerComposite methodAssemblerComposite() {
        return new MethodAssemblerComposite();
    }

    @Bean
    public InjectHandler injectHandler() {
        return new InjectHandler();
    }

    @Bean
    public MethodAssembler interDefaultMethodAssembler() {
        return new InterDefaultMethodAssembler();
    }

    @Bean
    public MethodAssembler modelPropertyAssembler() {
        return new ModelPropertyAssembler();
    }

    @Bean
    public AssembleHandlerComposite assembleHandlerComposite() {
        return new AssembleHandlerComposite();
    }

    @Bean
    public AssembleConverterComposite assembleConverterComposite(){
        return new AssembleConverterComposite();
    }

    @Bean
    public IntegerToCodeEnumConverter integerToCodeEnumConverter(){
        return new IntegerToCodeEnumConverter<>();
    }

    @Bean
    public AssembleForTargetClassHandler targetArrayHandler() {
        return new TargetArrayHandler();
    }

    @Bean
    public AssembleForTargetClassHandler standardTargetClassHandler() {
        return new StandardTargetClassHandler();
    }

    @Bean
    public AssembleForTargetClassHandler targetReferenceHandler() {
        return new TargetReferenceHandler();
    }

    @Bean
    public AssembleForTargetParameterizedTypeHandler targetCollectionHandler() {
        return new TargetCollectionHandler();
    }

    @Bean
    public AssembleForTargetParameterizedTypeHandler targetMapHandler() {
        return new TargetMapHandler();
    }

    @Bean
    public AssembleForTargetParameterizedTypeHandler standardTargetParameterizedTypeHandler() {
        return new StandardTargetParameterizedTypeHandler();
    }

}